<%-- 
    Document   : nuevoCategoriaCliente
    Created on : 01-sep-2012, 19:44:02
    Author     : ADMIN
--%>

<%@page import="Entities.Tipocliente"%>
<%@page import="Entities.Categoriacliente"%>
<%@page import="Entities.Nivelusuario"%>
<%@page import="java.util.Iterator"%>
<%@page import="javax.persistence.Query"%>
<%@page import="javax.persistence.Persistence"%>
<%@page import="javax.persistence.EntityManager"%>
<%@page import="javax.persistence.EntityManagerFactory"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <form name="form1" method="post" action="http://localhost:8080/appwebdizucar/nuevoCategoriaCliente">
  <table width="255" border="0" align="center">
    <tr>
      <td colspan="2" align="center" valign="middle">NUEVA CATEGORIA DE CLIENTE</td>
    </tr>
    <tr>
      <td>Categoria:</td>
      <td><label for="txtcatclinte"></label>
      <input type="text" name="txtcatclinte" id="txtcatclinte"></td>
    </tr>
    <tr>
      <td>Tipo de Clinte:</td>
      <td><label for="cbtipocliente"></label>
        
          <%
                try
                    {
                        EntityManagerFactory emf=Persistence.createEntityManagerFactory("PU");
                        EntityManager em=emf.createEntityManager();
                        Query result = em.createNamedQuery("Tipocliente.findAll");
                        String tipo;
                        int nivelid;
                            java.util.List tipoClienteList = result.getResultList();
                            Iterator itr=tipoClienteList.iterator();
                            out.println("<select name='cbtipocliente' id='cbtipocliente'>");
                            while(itr.hasNext())
                            {
                                Tipocliente tc=(Tipocliente)itr.next();
                                tipo=tc.getNombretipocliente();
                                nivelid=tc.getIdtipocliente();
                                out.println("<option value="+nivelid+">"+tipo+"</option>");
                            }

                    out.println("</select></td>");
                    em.close();emf.close();
                 }catch(Exception e){
                     System.err.println(e.toString()+"dinora");
                 }
                        
                %>

      </select>        <label for="txtcatclinte"></label></td>
          
      <td><input type="submit" name="btnok" id="btnok" value="Aceptar"></td>
      <td align="right"><input type="reset" name="btncancel" id="btncancel" value="Cancelar"></td>
    </tr>
  </table>
</form>
        
    </body>
</html>
